package com.example.springboot_test.easyexcel.model;

import com.example.springboot_test.easyexcel.model.builder.PictureModelBuilder;
import com.example.springboot_test.easyexcel.model.common.SheetRangeModel;
import lombok.Getter;

/**
 * 图片信息
 *
 * @author xudongmaster
 */
@Getter
public class PictureModel extends SheetRangeModel {
    /**
     * 图片数据
     */
    private final byte[] pictureBytes;
    /**
     * 图片类型
     */
    private final Integer pictureType;

    public PictureModel(PictureModelBuilder builder) {
        this.sheetName = builder.getSheetName();
        this.startRowIndex = builder.getStartRowIndex();
        this.endRowIndex = builder.getEndRowIndex();
        this.startColumnIndex = builder.getStartColumnIndex();
        this.endColumnIndex = builder.getEndColumnIndex();
        this.pictureBytes = builder.getPictureBytes();
        this.pictureType = builder.getPictureType();
    }

    /**
     * 生成图片信息
     *
     * @param sheetName        sheet页名称
     * @param startRowIndex    开始行号
     * @param endRowIndex      结束行号
     * @param startColumnIndex 开始列号
     * @param endColumnIndex   结束列号
     * @param pictureBytes     图片数据
     * @return 图片信息
     */
    public static PictureModel createPictureModel(String sheetName, int startRowIndex, int endRowIndex, int startColumnIndex, int endColumnIndex
            , byte[] pictureBytes) {
        return createPictureModel(sheetName, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex, pictureBytes, null);
    }


    /**
     * 生成图片信息
     *
     * @param sheetName        sheet页名称
     * @param startRowIndex    开始行号
     * @param endRowIndex      结束行号
     * @param startColumnIndex 开始列号
     * @param endColumnIndex   结束列号
     * @param pictureBytes     图片数据
     * @param pictureType      图片类型
     * @return 图片信息
     */
    public static PictureModel createPictureModel(String sheetName, int startRowIndex, int endRowIndex, int startColumnIndex, int endColumnIndex
            , byte[] pictureBytes, Integer pictureType) {
        return PictureModelBuilder.builder(sheetName, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex, pictureBytes)
                //图片类型
                .pictureType(pictureType)
                .build();
    }
}
